package p270jp.pxv.android.viewholder;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.measurement.internal.C2066a;
import com.google.firebase.analytics.FirebaseAnalytics;
import java.util.List;
import java.util.Objects;
import p045be.View$OnLongClickListenerC1082k0;
import p062c4.ViewBindings;
import p090d0.C2518n;
import p134ei.AnalyticsScreenName;
import p159fi.FirebaseEventLogger;
import p165fo.C3114c;
import p184gi.AnalyticsParameter;
import p184gi.FirebaseAnalyticsEventName;
import p270jp.pxv.android.R;
import p270jp.pxv.android.activity.IllustDetailPagerActivity;
import p270jp.pxv.android.event.ShowWorkMenuOnLongClickEvent;
import p270jp.pxv.android.legacy.constant.ContentType;
import p270jp.pxv.android.legacy.model.PixivIllust;
import p270jp.pxv.android.view.ThumbnailView;
import p274k2.ContextCompat;
import p314lg.ViewIllustCarouselItemBinding;
import p325m0.C4721b;
import p347mm.MuteManager;
import p350mp.Timber;
import p603wm.AbstractC6949c;
import p677zi.PixivImageLoader;

/* renamed from: jp.pxv.android.viewholder.IllustCarouselItemViewHolder */
/* loaded from: classes2.dex */
public class IllustCarouselItemViewHolder extends RecyclerView.AbstractC0819y {
    private ViewIllustCarouselItemBinding binding;
    private final ContentType contentType;
    private final AbstractC6949c<FirebaseEventLogger> firebaseEventLogger = C2518n.m7638h(FirebaseEventLogger.class);
    private final PixivImageLoader pixivImageLoader;
    private AnalyticsScreenName screenName;

    private IllustCarouselItemViewHolder(ViewIllustCarouselItemBinding o9Var, ContentType contentType, PixivImageLoader aVar, AnalyticsScreenName cVar) {
        super(o9Var.f22052a);
        this.binding = o9Var;
        this.contentType = contentType;
        this.pixivImageLoader = aVar;
        this.screenName = cVar;
    }

    /* renamed from: a */
    public static /* synthetic */ boolean m4430a(PixivIllust pixivIllust, View view) {
        return lambda$bindViewHolder$1(pixivIllust, view);
    }

    public static IllustCarouselItemViewHolder createViewHolder(ViewGroup viewGroup, ContentType contentType, PixivImageLoader aVar, AnalyticsScreenName cVar) {
        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.view_illust_carousel_item, viewGroup, false);
        int i = R.id.caption_container;
        RelativeLayout relativeLayout = (RelativeLayout) ViewBindings.m9835b(inflate, R.id.caption_container);
        if (relativeLayout != null) {
            i = R.id.thumbnail_view;
            ThumbnailView thumbnailView = (ThumbnailView) ViewBindings.m9835b(inflate, R.id.thumbnail_view);
            if (thumbnailView != null) {
                i = R.id.title_text_view;
                TextView textView = (TextView) ViewBindings.m9835b(inflate, R.id.title_text_view);
                if (textView != null) {
                    i = R.id.user_container;
                    LinearLayout linearLayout = (LinearLayout) ViewBindings.m9835b(inflate, R.id.user_container);
                    if (linearLayout != null) {
                        i = R.id.user_name_text_view;
                        TextView textView2 = (TextView) ViewBindings.m9835b(inflate, R.id.user_name_text_view);
                        if (textView2 != null) {
                            i = R.id.user_profile_image_view;
                            ImageView imageView = (ImageView) ViewBindings.m9835b(inflate, R.id.user_profile_image_view);
                            if (imageView != null) {
                                return new IllustCarouselItemViewHolder(new ViewIllustCarouselItemBinding((FrameLayout) inflate, relativeLayout, thumbnailView, textView, linearLayout, textView2, imageView), contentType, aVar, cVar);
                            }
                        }
                    }
                }
            }
        }
        throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
    }

    public /* synthetic */ void lambda$bindViewHolder$0(PixivIllust pixivIllust, Context context, List list, int i, View view) {
        sendClickAnalyticsEvent(pixivIllust.f19079id);
        context.startActivity(IllustDetailPagerActivity.m4822k1(context, list, i));
    }

    public static /* synthetic */ boolean lambda$bindViewHolder$1(PixivIllust pixivIllust, View view) {
        C3114c.m6284b().m6280f(new ShowWorkMenuOnLongClickEvent(pixivIllust));
        return true;
    }

    private void sendClickAnalyticsEvent(long j) {
        FirebaseAnalyticsEventName jVar = FirebaseAnalyticsEventName.CLICK;
        ContentType contentType = this.contentType;
        if (contentType == ContentType.ILLUST) {
            FirebaseEventLogger value = this.firebaseEventLogger.getValue();
            C4721b.m3752b(1, "via");
            Bundle bundle = new Bundle();
            bundle.putString("click_name", "open_content");
            bundle.putString("screen_name", "HomeIllust");
            bundle.putString("item_id", String.valueOf(j));
            bundle.putString("via", C2066a.m8760a(1));
            value.m6296f();
            Timber.f23100a.mo3528a("%s %s", jVar, String.valueOf(bundle));
            FirebaseAnalytics firebaseAnalytics = value.f14642a;
            Objects.requireNonNull(jVar);
            firebaseAnalytics.f10008a.zzx("click", bundle);
        } else if (contentType == ContentType.MANGA) {
            FirebaseEventLogger value2 = this.firebaseEventLogger.getValue();
            C4721b.m3752b(1, "via");
            Bundle bundle2 = new Bundle();
            bundle2.putString("click_name", "open_content");
            bundle2.putString("screen_name", "HomeManga");
            bundle2.putString("item_id", String.valueOf(j));
            bundle2.putString("via", C2066a.m8760a(1));
            value2.m6296f();
            Timber.f23100a.mo3528a("%s %s", jVar, String.valueOf(bundle2));
            FirebaseAnalytics firebaseAnalytics2 = value2.f14642a;
            Objects.requireNonNull(jVar);
            firebaseAnalytics2.f10008a.zzx("click", bundle2);
        }
    }

    public void bindViewHolder(List<PixivIllust> list, int i) {
        PixivIllust pixivIllust = list.get(i);
        this.binding.f22054c.setIllust(pixivIllust);
        this.binding.f22054c.setAnalyticsParameter(new AnalyticsParameter(this.screenName, null, 0));
        this.binding.f22054c.m4465c();
        if (MuteManager.f23061h.m3539d(pixivIllust)) {
            this.binding.f22053b.setVisibility(8);
            return;
        }
        this.binding.f22053b.setVisibility(0);
        ThumbnailView thumbnailView = this.binding.f22054c;
        FrameLayout frameLayout = thumbnailView.f19697b.f22165v;
        Context context = thumbnailView.getContext();
        Object obj = ContextCompat.f19963a;
        frameLayout.setForeground(ContextCompat.C4472c.m4259b(context, R.drawable.bg_ranking_cell_bottom_overlay));
        Context context2 = this.itemView.getContext();
        this.pixivImageLoader.m60f(context2, pixivIllust.user.profileImageUrls.getMedium(), this.binding.f22057f);
        this.binding.f22056e.setText(pixivIllust.user.name);
        this.binding.f22055d.setText(pixivIllust.title);
        this.binding.f22054c.setOnClickListener(new View.OnClickListener(pixivIllust, context2, list, i) { // from class: jp.pxv.android.viewholder.e

            /* renamed from: b */
            public final /* synthetic */ PixivIllust f19750b;

            /* renamed from: c */
            public final /* synthetic */ Context f19751c;

            /* renamed from: d */
            public final /* synthetic */ List f19752d;

            /* renamed from: e */
            public final /* synthetic */ int f19753e;

            {
                this.f19750b = r2;
                this.f19751c = r3;
                this.f19752d = r4;
                this.f19753e = r5;
            }

            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
                IllustCarouselItemViewHolder.this.lambda$bindViewHolder$0(this.f19750b, this.f19751c, this.f19752d, this.f19753e, view);
            }
        });
        this.binding.f22054c.setOnLongClickListener(new View$OnLongClickListenerC1082k0(pixivIllust, 2));
        this.binding.f22054c.m4464d(pixivIllust.imageUrls.getSquareMedium(), 15);
    }
}
